package com.wangyk.rabbitmqconsole.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Description:
 * 将过滤器给spring管理，@Component注册过滤器
 * @Author: wangyk
 * @CreateDate: 2018/11/27$ 9:05$
 * @UpdateUser: wangyk
 * @UpdateDate: 2018/11/27$ 9:05$
 * @UpdateRemark:
 * @Version: 1.0
 */
public class KeywordHandleFilter implements Filter
{
    /**
     * 日志打印
     */
    private Logger logger = LoggerFactory.getLogger(KeywordHandleFilter.class);

    public void init(FilterConfig filterConfig)
        throws ServletException
    {
        System.out.println("KeywordHandleFilter初始化！");
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws IOException, ServletException
    {
        System.out.println("执行KeywordHandleFilter的：doFilter()方法！==>"+((HttpServletRequest)request).getRequestURI());
        //可以执行后面的过滤器
        filterChain.doFilter(request,response);
    }

    public void destroy()
    {
        System.out.println("KeywordHandleFilter销毁！");
    }
}
